package com.xoa.controller.attendance;

import com.xoa.model.attendance.LeaveStatistics;
import com.xoa.service.attendance.LeaveStatisticsService;
import com.xoa.util.CookiesUtil;
import com.xoa.util.ToJson;
import com.xoa.util.common.session.SessionUtils;
import com.xoa.util.dataSource.ContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 类介绍：请假申请
 * 日期：2018-06-27
 * 作者：王禹萌
 */
@Controller
@RequestMapping("/manage")
public class LeaveStatisticsController {
@Resource
 private LeaveStatisticsService leaveStatisticsService;

    //请假统计菜单映射
//    @ResponseBody
    @RequestMapping("/leaveStatistics")
    public String leaveStatistics(HttpServletRequest request) {
        Cookie redisSessionCookie = CookiesUtil.getCookieByName(request, "redisSessionId");
        String loginDateSouse = SessionUtils.getSessionInfo(request.getSession(), "loginDateSouse", String.class, redisSessionCookie);
        ContextHolder.setConsumerType("xoa" + loginDateSouse);
        return "app/attendance/manage/leaveStatistics";
    }

    /**
     * 查询请假申请
     * 王禹萌
     * 时间：2018-06-27 20：31：45
     * @param DATA_162 开始时间
     * @param DATA_163 结束时间
     * @param type 查询人类型 1班主任 2 非班主任 3总务后勤 4 行政
     * @return
     */
    @RequestMapping("/leaveStatisticsQuery")
    @ResponseBody
    public ToJson leaveStatisticsQuery(@RequestParam("DATA_162")String DATA_162,
                                            @RequestParam("DATA_163")String DATA_163,
                                            @RequestParam("type")String type,
                                       Integer page, Integer pageSize, boolean useFlag){
        return leaveStatisticsService.leaveStatisticsQuery(DATA_162,DATA_163,type,page,pageSize,useFlag);
    }

    /**
     * 导出请假统计
     * 王禹萌
     * 时间：2018-06-28
     * @param request
     * @param response
     * @param DATA_162 开始时间
     * @param DATA_163 结束时间
     * @param type 查询人类型 1班主任 2 非班主任 3总务后勤 4 行政
     * @return
     */
    @RequestMapping("/leaveStatisticsExport")
    @ResponseBody
    public LeaveStatistics leaveStatisticsExport(HttpServletRequest request,
                                                 HttpServletResponse response,
                                                 @RequestParam("DATA_162")String DATA_162,
                                                 @RequestParam("DATA_163")String DATA_163,
                                                 @RequestParam("type")String type){

        return leaveStatisticsService.leaveStatisticsExport(request,response,DATA_162,DATA_163,type);
    }

}
